package com.shuaiche.yeguan.ui.upload;

import com.shuaiche.yeguan.model.SCCarPicsModel;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

public class UploadPagerAdapter extends FragmentStateAdapter {
    private final List<Fragment> fragments;

    public UploadPagerAdapter(FragmentActivity activity, ArrayList<String> carPicsList, ArrayList<SCCarPicsModel> certPicsList,ArrayList<String> otherPicsList) {
        super(activity);
        fragments = new ArrayList<>();
        fragments.add(CarPictureFragment.newInstance(carPicsList));
        fragments.add(DocumentFragment.newInstance(certPicsList));
        fragments.add(OtherPictureFragment.newInstance(otherPicsList));
    }

    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }

    public List<Fragment> getFragments() {
        return fragments;
    }

    public CarPictureFragment getCarPictureFragment(){
        return (CarPictureFragment)fragments.get(0);
    }

    public DocumentFragment getDocumentFragment(){
        return (DocumentFragment)fragments.get(1);
    }

    public OtherPictureFragment getOtherPictureFragment(){
        return (OtherPictureFragment)fragments.get(2);
    }
}